package logic

import (
	"context"
	"fmt"
	"jd-mall/models/cache"
	"strconv"

	"jd-mall/jd_srv/internal/svc"
	"jd-mall/jd_srv/jd_srv"

	"github.com/zeromicro/go-zero/core/logx"
)

type DelShoppingCartLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDelShoppingCartLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DelShoppingCartLogic {
	return &DelShoppingCartLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *DelShoppingCartLogic) DelShoppingCart(in *jd_srv.DelShoppingCartRequest) (*jd_srv.DelShoppingCartResponse, error) {
	// todo: add your logic here and delete this line
	err := cache.RDB.Del(l.ctx, "shopId:"+strconv.Itoa(int(in.ShopId))).Err()
	if err != nil {
		return nil, fmt.Errorf("删除失败")
	}
	return &jd_srv.DelShoppingCartResponse{}, nil
}
